package com.atguigu.staservice.controller;


import com.atguigu.common.R;
import com.atguigu.staservice.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Panghl
 * @since 2021-02-24
 */
@RestController
@RequestMapping("/staservice/statistics-daily")
@Api(tags = {"统计分析"})
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService staService;

    @ApiOperation(value = "统计某一天的注册人数,生成统计数据")
    @PostMapping("/registerCount/{day}")
    public R registerCount(@PathVariable("day")String day){
        staService.registerCount(day);
        return R.ok();
    }

    @ApiOperation(value = "图表显示，返回两部分数据，日期json数组，数量json数组")
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type")String type,
                      @PathVariable("begin")String begin,
                      @PathVariable("end")String end){
        Map<String,Object> map = staService.getShowData(type,begin,end);
        return R.ok().data("data",map);
    }
}
